import pygame
import sys
import time
import random
from pygame.locals import *
from pygame.sprite import Group
from buttons import *

screen_dimension = ( 800, 400 ) 

# loading background image
doomBackground = pygame.image.load('doom.png')
# change image scale to fit screen
doomBackground = pygame.transform.scale( doomBackground, screen_dimension)
# init pygame
pygame.init()
# set window title
pygame.display.set_caption('Doom Game')
# set screen dimensions
#screen = pygame.display.set_mode( (800,400), pygame.FULLSCREEN )
screen = pygame.display.set_mode( screen_dimension )

unit_buttons = Buttons(0,["slinger","clubman","speedy_dino"])
turret_buttons = Buttons(unit_buttons.get_width() + 40,["mamooth_catapult","egg_rifle"] )

# all pygame programs have True loops
while True:
    # paint the background image
    screen.blit( doomBackground, (0,0))
    # draw the sprites
    unit_buttons.draw(screen)
    turret_buttons.draw(screen)  
        
    # take care of key events
    for event in pygame.event.get():
        if event.type == KEYDOWN:
            # detect exit game                       
            if event.key == K_ESCAPE:
                sys.exit() # exit game   
    
    # tell pygame to draw changes
    pygame.display.update()
    # sleep, wait. 
    time.sleep(0.06)